<%-- 
    Document   : indexManterPortlets
    Created on : 03/09/2011, 15:57:51
    Author     : Rafael Quintino
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<tiles:insertTemplate template="/WEB-INF/template/template001.jsp" flush="true" >

    <tiles:putAttribute name="title" cascade="true">Portfull</tiles:putAttribute>
    <tiles:putAttribute name="keywords" cascade="true">dinheiro, publicidade</tiles:putAttribute>
    <tiles:putAttribute name="description" cascade="true">ganhe dinheiro</tiles:putAttribute>

    <tiles:putAttribute name="css_extension" cascade="true">
        <%--link rel="stylesheet" type="text/css" href="<c:url value="/css/home.css"/>" /--%>
    </tiles:putAttribute>
    <tiles:putAttribute name="js_extension" cascade="true">
        <script charset="utf-8" type="text/javascript" />
        //<![CDATA[
            jQuery(document).ready(function() {
                $('#btn').click (
                    function () {
                        var valores = "empresaDTO.nome=" + $('#nome').val() +
                                      "&empresaDTO.email=" + $('#email').val() +
                                      "&empresaDTO.senha=" + $('#senha').val() +
                                      "&empresaDTO.cpfCnpj=" + $('#cpfCnpj').val();
                        $.ajax({
                          url: "<c:url value="/rest/empresa/"/>",
                          dataType:"json",
                          type:"POST",
                          data:"" + valores,
                          success: function(data, textStatus, jqXHR){
                            alert(data + " - " + textStatus);
                          }
                        });
                    }
                );

                $('#btn2').click (
                    function () {
                        var valores = "empresaDTO.nome=" + $('#nome').val() +
                                      "&empresaDTO.email=" + $('#email').val() +
                                      "&empresaDTO.senha=" + $('#senha').val() +
                                      "&empresaDTO.cpfCnpj=" + $('#cpfCnpj').val() +
                                      "&_method=PUT";
                        $.ajax({
                          url: "<c:url value="/rest/empresa/59ed5ed5-3429-47ac-a7ad-9d7bafe35f16"/>",
                          dataType:"json",
                          type:"GET",
                          data:"" + valores,
                          success: function(data, textStatus, jqXHR){
                            alert(data + " - " + textStatus);
                          }
                        });
                    }
                );
            });
        //]]>
        </script>
    </tiles:putAttribute>

    <tiles:putAttribute name="aside" cascade="true">
        <pre>Aside - Portfull!!!</pre>
    </tiles:putAttribute>
    
    <tiles:putAttribute name="section" cascade="true">
        <pre>Section - Portfull!!!</pre>
        <form id="persist" method="POST" action="<c:url value="/rest/empresa"/>">
            <input type="hidden" name="_method" value="POST"/>
            Nome: <input type="text" name="empresaDTO.nome" id="nome" value=""/>
            E-mail: <input type="text" name="empresaDTO.email" id="email" value=""/>
            senha: <input type="password" name="empresaDTO.senha" id="senha" value=""/>
            cpfCnpj: <input type="text" name="empresaDTO.cpfCnpj" id="cpfCnpj" value=""/>
        </form>
        <input type="submit" value="registrar" id="btn" />
        <input type="submit" value="consultarTESTE" id="btn2" />
    </tiles:putAttribute>

</tiles:insertTemplate>
